// pages/user/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    isLogin: true,
    defaultURL:
      "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1585988335284&di=9a36cf1a85078caa661ce449447b327c&imgtype=0&src=http%3A%2F%2Fimg.jk51.com%2Fimg_jk51%2F362609601.jpeg",
      payAll:[
        {
          title:"待付款",
          id:2,
          icon:"icon-icon_coinpurse_line"
        },
        {
          title:"待收货1",
          id:3,
          icon:"icon-icon_dingtalk_line"
        },
        {
          title:"退款/退款",
          id:undefined,
          icon:"icon-icon_exchange"
        },
        {
          title:"全部订单",
          id:1,
          icon:"icon-icon_doc"
        },
      ]
 
    },
    
  getUserInfo(e) {
    console.log("e: ", e);
    const userInfo = e.detail;
    console.log("userInfo: ", userInfo);
    this.setData({
      userInfo,
      isLogin: false
    });
    // console.log('this.data.isLogin: ', this.data.isLogin);
    wx.setStorageSync("userInfo", userInfo);
  },
  // 页面跳转
  goToOrder(e){
    const {id} = e.currentTarget.dataset;
    if (id) {
      wx.navigateTo({
        url: '/pages/order/index?id='+id,
      });
        
    }
    
  },
  onShow() {
    const userInfo = wx.getStorageSync("userInfo") || false;
    if (userInfo) {
      this.setData({
        userInfo,
        isLogin: false
      });
    }
  }
});
